package com.no.hq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue simpleQueue() {
        return new Queue("my_simple_queue");
    }

    @Bean
    public Queue workQueue() {
        return new Queue("my_work_queue");
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("my_topic_exchange");
    }

    @Bean
    public Queue queue1() {
        return new Queue("topic_queue1");
    }

    @Bean
    public Queue queue2() {
        return new Queue("topic_queue2");
    }

    @Bean
    public Binding topicExchangeQueue1(TopicExchange topicExchange, Queue queue1){
        return BindingBuilder.bind(queue1()).to(topicExchange()).with("topic.*.orange");
    }

    @Bean
    public Binding topicExchangeQueue2(TopicExchange topicExchange, Queue queue2){
        return BindingBuilder.bind(queue2()).to(topicExchange()).with("topic.#");
    }

}
